package sf.jaxb.model;


import java.util.Date;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name = "book")
@XmlType(propOrder = {
    "id",
    "author",
    "name",
    "publisher",
    "isbn",
    "publicationDate",
    "forChildren"
})
public class Book
{

  private Long id;
  private String name;
  private String author;
  private String publisher;
  private String isbn;
  private Date publicationDate;
  private Boolean forChildren;

  @Override
  public boolean equals(final Object obj)
  {
    if (this == obj)
    {
      return true;
    }
    if (obj == null)
    {
      return false;
    }
    if (getClass() != obj.getClass())
    {
      return false;
    }
    final Book other = (Book) obj;
    if (author == null)
    {
      if (other.author != null)
      {
        return false;
      }
    }
    else if (!author.equals(other.author))
    {
      return false;
    }
    if (forChildren == null)
    {
      if (other.forChildren != null)
      {
        return false;
      }
    }
    else if (!forChildren.equals(other.forChildren))
    {
      return false;
    }
    if (id == null)
    {
      if (other.id != null)
      {
        return false;
      }
    }
    else if (!id.equals(other.id))
    {
      return false;
    }
    if (isbn == null)
    {
      if (other.isbn != null)
      {
        return false;
      }
    }
    else if (!isbn.equals(other.isbn))
    {
      return false;
    }
    if (name == null)
    {
      if (other.name != null)
      {
        return false;
      }
    }
    else if (!name.equals(other.name))
    {
      return false;
    }
    if (publicationDate == null)
    {
      if (other.publicationDate != null)
      {
        return false;
      }
    }
    else if (!publicationDate.equals(other.publicationDate))
    {
      return false;
    }
    if (publisher == null)
    {
      if (other.publisher != null)
      {
        return false;
      }
    }
    else if (!publisher.equals(other.publisher))
    {
      return false;
    }
    return true;
  }

  public String getAuthor()
  {
    return author;
  }

  public Boolean getForChildren()
  {
    return forChildren;
  }

  public Long getId()
  {
    return id;
  }

  public String getIsbn()
  {
    return isbn;
  }

  @XmlElement(name = "title")
  public String getName()
  {
    return name;
  }

  public Date getPublicationDate()
  {
    return publicationDate;
  }

  //@XmlElement(nillable = true)
  public String getPublisher()
  {
    return publisher;
  }

  @Override
  public int hashCode()
  {
    final int prime = 31;
    int result = 1;
    result = prime * result + (author == null? 0: author.hashCode());
    result = prime * result + (forChildren == null? 0: forChildren.hashCode());
    result = prime * result + (id == null? 0: id.hashCode());
    result = prime * result + (isbn == null? 0: isbn.hashCode());
    result = prime * result + (name == null? 0: name.hashCode());
    result = prime * result
             + (publicationDate == null? 0: publicationDate.hashCode());
    result = prime * result + (publisher == null? 0: publisher.hashCode());
    return result;
  }

  public void setAuthor(final String author)
  {
    this.author = author;
  }

  public void setForChildren(final Boolean forChildren)
  {
    this.forChildren = forChildren;
  }

  public void setId(final Long id)
  {
    this.id = id;
  }

  public void setIsbn(final String isbn)
  {
    this.isbn = isbn;
  }

  public void setName(final String name)
  {
    this.name = name;
  }

  public void setPublicationDate(final Date publicationDate)
  {
    this.publicationDate = publicationDate;
  }

  public void setPublisher(final String publisher)
  {
    this.publisher = publisher;
  }

  @Override
  public String toString()
  {
    return "Book [id=" + id + ", name=" + name + ", author=" + author
           + ", publisher=" + publisher + ", isbn=" + isbn
           + ", publicationDate=" + publicationDate + ", forChildren="
           + forChildren + "]";
  }

}
